package com.btks.jswater.controller;


import com.btks.jswater.entity.WaterMoniData;
import com.btks.jswater.entity.WaterPointRelationTable;
import com.btks.jswater.entity.WaterRelationPoint;
import com.btks.jswater.entity.WaterDirectonJson;
import com.btks.jswater.service.impl.CountServiceImpl;
import com.btks.jswater.service.impl.ReservoirInfoServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Api(tags = "图层信息查询")
@Controller
@RequestMapping("/waterInfo")
public class WaterInfoController {
    @Autowired
    private CountServiceImpl countService;
    @Autowired
    private ReservoirInfoServiceImpl   reservoirInfoService;
    @ApiOperation("按照对应编号查询工程信息,1:水电站，2:水渠 3：地下水 4：团场区划 5：水闸" +
            " 6：灌区测水 7：人饮 8：水文测站 9河流 10水库 ")
    @GetMapping("/getInfo")
    @ResponseBody
    public Object getInfo(String key, @ApiParam("页码")@RequestParam("pageNo")int pnum,@ApiParam("页面大小")@RequestParam("pageSize") int nnum){
        return  countService.getWaterInfoList(key,pnum,nnum);
    }
    @ApiOperation("按照编号查询，先查种类再查gid,1:水电站，2:水渠 3：地下水 4：团场区划 5：水闸" +
            " 6：灌区测水 7：人饮 8：水文测站 9河流 10水库 ")
    @GetMapping("/getInfoByid")
    @ResponseBody
    public Object getInfo(String key, @ApiParam("GID")@RequestParam("gid") String gid){
        return  countService.getWaterInfoById(key,gid);}
    @ApiOperation("水流方向-查询相关的节点")
    @GetMapping("/getRelaByid")
    @ResponseBody
    public List<WaterRelationPoint> getRelaInfo(String id){
        return  reservoirInfoService.getRealtion(id);
    }
    @ApiOperation("水流方向-返回相关方向点数组")
    @GetMapping("/getDicByid")
    @ResponseBody
    public  List<WaterDirectonJson> getDirectionsInfo(String id){
        return  reservoirInfoService.getDirections(id);
    }
    @ApiOperation("水流方向-返回渠系关系表")
    @GetMapping("/getDicTable")
    @ResponseBody
    public WaterPointRelationTable getDirectionsTable(@ApiParam("水库编号")@RequestParam("code")String code){
        return  reservoirInfoService.getPointTable(code);
    }
    @ApiOperation("水流方向-返回站点详细信息")
    @GetMapping("/getStcdInfo")
    @ResponseBody
    public List<WaterMoniData> getStcdInfo(@ApiParam("监测站编号，STCD")@RequestParam("code")String code){
        return  reservoirInfoService.getStInfo(code);
    }

    @ApiOperation("详细信息-按起止时间和编号")
    @GetMapping("/getInfoByTime")
    @ResponseBody
    public List<WaterMoniData> getInfoByTime(@ApiParam("监测站编号，STCD")@RequestParam("code")String code,
                                             @ApiParam("监测站编号，stime")@RequestParam("stime")String stime,
                                             @ApiParam("监测站编号，etime")@RequestParam("etime")String etime){
        return  reservoirInfoService.getInfoByTime(stime,etime,code);
    }

    @ApiOperation("渠系关系表中详细信息-平均流量")
    @GetMapping("/getTableInfoByTime")
    @ResponseBody
    public float getTableInfoByTime(@ApiParam("监测站编号，STCD")@RequestParam("code")String code,
                                             @ApiParam("监测站编号，stime")@RequestParam("stime")String stime,
                                             @ApiParam("监测站编号，etime")@RequestParam("etime")String etime){
        return  reservoirInfoService.getTableCountInfo(stime,etime,code);
    }

    @ApiOperation("按水库时间段查询")
    @GetMapping("/getMoniData")
    @ResponseBody
    public List<Map> getMoniData(@ApiParam("水库编号，STCD")@RequestParam("code")String code,
                                 @ApiParam("开始时间，stime")@RequestParam("stime")String stime,
                                 @ApiParam("结束时间，etime")@RequestParam("etime")String etime){
        return  reservoirInfoService.getMoniData(stime,etime,code);
    }
    @ApiOperation("按时间查询水库龙口水量")
    @GetMapping("/getSumDataByDate")
    @ResponseBody
    public List<WaterMoniData> getSumDataByDate(@ApiParam("水库编号，STCD")@RequestParam("code")String code,
                                 @ApiParam("开始时间，stime")@RequestParam("stime")String stime,
                                 @ApiParam("结束时间，etime")@RequestParam("etime")String etime){
        return  reservoirInfoService.getSumDataByDate(stime,etime,code);
    }

}
